
#ifndef __GLOBALUSERFUNC_H__
#define __GLOBALUSERFUNC_H__

#include "includes.h"

#define  HIBYTE(v1)             ((uint8_t)((v1)>>8))
#define  LOBYTE(v1)             ((uint8_t)((v1)&0xff))

#define  HIWORD(v1)             ((uint16_t)((v1)>>16))
#define  LOWORD(v1)             ((uint16_t)((v1)&0xffff))

#define  MGetBit(REG, BIT)      (((REG) & (BIT))?1:0)
#define  MSetBit(REG, BIT)      ((REG) |= (BIT))
#define  MClearBit(REG, BIT)    ((REG) &= ~(BIT))


#define  ITEM_NUM(n)            (sizeof(n)/sizeof(n[0]))




extern uint16_t GetU16(void* value);
extern uint16_t GetU16_R(void* value);
extern void SetU16(void* value, uint16_t fact);
extern void SetU16_R(void* value, uint16_t fact);
extern uint32_t GetU32(void* value);
extern uint32_t GetU32_R(void* value);
extern uint32_t GetU32_M(void* value);
extern void SetU32(void* value, uint32_t fact);
extern void SetU32_R(void* value, uint32_t fact);
extern void SetU32_M(void* value, uint32_t fact);

extern uint8_t CalCrc8(uint8_t *id, uint8_t len);
extern void CalCrc16(uint8_t *pBuf,uint16_t* CalcCRC, uint32_t size);

#endif /* __GLOBALUSERFUNC_H__ */

